package com.api.gbhg.liubing.dao;

import com.api.gbhg.liwenjun.VersionFlowUtil;
import com.api.gbhg.zengping.dao.PropertyManagementCostDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import weaver.conn.RecordSet;
import weaver.conn.RecordSetTrans;
import weaver.interfaces.workflow.action.Action;

/**
 * @author : liubing
 * @date :  2020/12/30 10:31
 * 不占编合同工劳务费
 */
public class NotForContractWorkersDao {
    public static final Logger LOGGER= LoggerFactory.getLogger(PropertyManagementCostDao.class);
    //查看  不占编合同工劳务费 主表数据
    public RecordSetTrans getMainTable(String requestId){
        RecordSetTrans rts=new RecordSetTrans();
        StringBuffer sb=new StringBuffer();
        String sql ="select v.lcjlsqjlid,v.lcid,v.xmmin,v.sbdw,v.sbks,v.jbr,v.yszje,b.hwgz,b.gc,b.fw,b.xecg,b.requestId " +
                "from uf_jingfei_version v INNER JOIN uf_bzbhtglwf b on v.lcjlsqjlid =b.requestId where b.requestId in (" + requestId +")";
        sb.append(sql);
        try {
//            if(status.equals("3")){
//                sb.append(" AND lcztz="+status);
//            }else {
//                sb.append(" AND lcztz<> 3");
//            }
//            //通过分页公式计算下一页在哪一行开始
//            //如1，10，1-1 = 0，那第一条开始显示下面十条，第一页
//            //如2，10，(2-1)乘以10 = 10，那就是第十条开始显示下面十条，第二页
//            // 判断是mysql 还是sqlserver
//            pageNum=(pageNum-1)*pageSize;
//            if("sqlserver".equals(rts.getDBType())){
//                sb.append(" order by v.Id offset "+pageNum+" rows fetch next "+pageSize+" rows only");
//            }else if("mysql".equals(rts.getDBType())){
//                sb.append(" LIMIT "+pageNum+","+pageSize+"");
//            }
            LOGGER.info("不占编合同工劳务费主表sql:--->"+sb.toString());
            rts.executeQuery(sb.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
        return rts;
    }
    //获取数据条数
    public int getMainTableCount(String status){
        RecordSet rs = new RecordSet();
        String StrSQL ="select  COUNT(1)AS num from uf_jingfei_version v INNER JOIN uf_bzbhtglwf b on v.lcjlsqjlid =b.requestId where 1=1";
        if(status.equals("3")){
            StrSQL=StrSQL+(" AND lcztz="+status);
        }else {
            StrSQL=StrSQL+(" AND lcztz<> 3");
        }
        LOGGER.info("教育培训经费总条数sql:--->"+StrSQL);
        rs.executeQuery(StrSQL);
        rs.next();
        return rs.getInt("num");
    }
    //查看  不占编合同工劳务费 明细表数据
     public RecordSet getDetailedTable(String requestid,int table){
         RecordSet rs = new RecordSet();
         String StrSQL="";
         if (table==1){
              StrSQL = "select * from uf_bzbhtglwf_dt1 where mainid="+"(select id from uf_bzbhtglwf where requestid=" + requestid+")"; //获取明细条1
         }else if (table==2){
              StrSQL = "select * from uf_bzbhtglwf_dt2 where mainid="+"(select id from uf_bzbhtglwf where requestid=" + requestid+")"; //获取明细条2
         }
         LOGGER.info("不占编合同工劳务费明细表sql:--->"+StrSQL);
         rs.executeQuery(StrSQL);
         return rs;
     }

    //查看 不占编合同工劳务费 数据
    public RecordSet getServiceFeeWarehousing(String requestid){
        RecordSet rs = new RecordSet();
        String StrSQL="select v.jbr,v.sbdw,v.xmmin,v.lcbj,v.lcjlsqjlid,v.gkdw,v.sydw,d.bmyszcjjfl,d.dyzfjjfl,v.ysnd,v.yszje,d.hjwy from uf_jingfei_version v " +
                "INNER JOIN uf_bzbhtglwf b ON v.requestId=b.requestId INNER JOIN uf_bzbhtglwf_dt2 d ON d.mainid= b.id WHERE v.requestId=" + requestid;
        LOGGER.info("不占编合同工劳务费入库sql:--->"+StrSQL);
        rs.executeQuery(StrSQL);
        return rs;
    }



}
